#include <node.h>
#include "opencl/icl.h"

namespace jsmodule
{
	using v8::FunctionCallbackInfo;
	using v8::Integer;
	using v8::Isolate;
	using v8::Local;
	using v8::Number;
	using v8::Object;
	using v8::String;
	using v8::Value;
	using v8::Exception;
	using v8::Context;

	void GetPlatformIDs(const FunctionCallbackInfo<Value> &args)
	{
		Isolate *isolate = args.GetIsolate();

		cl_platform_id *ids;
		size_t size;
		unsigned err = icl::getPlatformIDs(&ids, &size);
		if (err != icl::NO_ERR) {
			isolate->ThrowException(
				String::NewFromUtf8(isolate, icl::getErrMessage(err)).ToLocalChecked());
		}

		Local<Object> obj = Object::New(isolate);
		Local<Context> context = Context::New(isolate);
		obj->Set(context, 
			String::NewFromUtf8(isolate, "ids").ToLocalChecked(),
			);
		args.GetReturnValue().Set(obj);
	}

	void GetPlatformInfo(const FunctionCallbackInfo<Value> &args)
	{

	}

	void init(Local<Object> exports)
	{
		NODE_SET_METHOD(exports, "add", Add);
	}

	NODE_MODULE(NODE_GYP_MODULE_NAME, init)

}